package com.chat.api.service.Impl;

import com.chat.api.request.ChatRequest;
import com.chat.api.service.chatService;
import com.theokanning.openai.completion.CompletionRequest;
import com.theokanning.openai.service.OpenAiService;
import org.springframework.stereotype.Service;

@Service
public class chatServiceImpl implements chatService {
    @Override
    public String chatMsg(ChatRequest chatRequest) {
//        String token = "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";//System.getenv("OPENAI_TOKEN");
//
//        OpenAiService service = new OpenAiService(token);
//        CompletionRequest completionRequest = CompletionRequest.builder()
//                .model("text-davinci-003")
//                .prompt("今天天气怎么样？")
//                .temperature(0.5)
//                .maxTokens(2048)
//                .topP(1D)
//                .frequencyPenalty(0D)
//                .presencePenalty(0D)
//                .build();
//        try {
//            service.createCompletion(completionRequest).getChoices().forEach(System.out::println);
//        } catch (Exception e) {
//            System.err.println("Socket timeout. Please check your network connection and try again.");
//            // 这里你可以添加重试逻辑，或者结束程序等处理
//        }
        return "测试你好啊啊啊啊啊啊啊啊啊啊啊啊！！";
    }
}
